<?php
namespace Common\Model;

use Think\Model;

class BaseModel extends Model {

    /**
     * 保存或修改
     * @param $data
     * @return array
     */
    public function store($data){
        if ($this->create($data)) {
            $action = isset($data[$this->pk]) ? 'save' : 'add';
            $res = $this->$action($data);
            return ['status' => 'success', 'data' => $res, 'message' => '设置成功!'];
        }
        return ['status' => 'error', 'message' => $this->getError()];
    }

}